/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aaron.platform.entity;

import com.aaron.platform.view.FacesUtil;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Cascade;

/**
 *
 * @author mac
 */
@Entity
@Table(name = "gczx_payment_info")
@SequenceGenerator(name="GCZX_PAYMENTINFO_GENERATOR", sequenceName="GCZX_PAYMENTINFO_GENERATOR", allocationSize = 1)
@NamedQueries({
    @NamedQuery(name = "gczxPaymentInfo.findAll", query = "SELECT f FROM GczxPaymentInfo f")})
public class GczxPaymentInfo extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String SERIAL_NO = "serialNo";

    public static final String INVOICE_NO = "invoiceNo";

    public static final String INVOICE_VALUE = "invoiceValue";

    public static final String PAY_PRO = "payPro";

    public static final String PAY_DATE = "payDate";

    public static final String ENTERPRISE_ID = "enterpriseInfo.enterpriseId";

    public static final String CONTACT_CODE = "contactCode";

    public static final String PAY_REMARK = "payRemarks";

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator="GCZX_PAYMENTINFO_GENERATOR")
    @Column(name = "pay_id")
    private Integer payId;

    /** 付款流水号 */
    @Column(name = "serial_no")
    private String serialNo;

    /** 发票编号 */
    @Column(name = "invoice_no")
    private String invoiceNo;

    /** 发票金额 */
    @Column(name = "invoice_value")
    private double invoiceValue;

    /** 付款金额 */
    @Column(name = "pay_value")
    private double payValue;

    /** 发票收到时间 */
    @Column(name = "invoice_submit_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date invSubdate;

    /** 所属专业 */
    @Column(name = "pay_pro")
    private int payPro;

    /** 投资界面 */
    @Column(name = "invest_interface")
    private int investInterface;

    @Column(name = "is_payed")
    private boolean payed;

    /** 付款提交时间 */
    @Column(name = "pay_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date payDate;

    @Column(name = "pay_type")
    private int payType;

    /** 付款说明 */
    @Column(name = "payment_help")
    private String payHelp;

    /** 备注 */
    @Column(name = "payment_remarks")
    private String payRemarks;

    /** 对应的单位信息 */
    @JoinColumn(name = "enterprise_id", referencedColumnName = "enterprise_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private FgysEnterprise enterpriseInfo;

    /** 付款明细列表 */
    @OneToMany(mappedBy = "paymentInfo", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @Cascade (org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
    private List<GczxPayDetail> payDetails;

    public GczxPaymentInfo() {
        this.invoiceNo = "";
        this.payHelp = "";
        this.payRemarks = "";
        this.serialNo = "";
        this.enterpriseInfo = new FgysEnterprise();
    }

//    public void initial() {
//        this.invoiceNo = "";
//        this.payHelp = "";
//        this.payRemarks = "";
//        this.serialNo = "";
//        this.enterpriseInfo = new FgysEnterprise();
////        this.enterpriseInfo.setEnterpriseId(0);
//    }

    public Date getInvSubdate() {
        return invSubdate;
    }

    public void setInvSubdate(Date invSubdate) {
        this.invSubdate = invSubdate;
    }

    public String getInvoiceNo() {
        return invoiceNo;
    }

    public void setInvoiceNo(String invoiceNo) {
        this.invoiceNo = invoiceNo;
    }

    public double getInvoiceValue() {
        return invoiceValue;
    }

    public double getPayValue() {
        return payValue;
    }

    public void setPayValue(double payValue) {
        this.payValue = payValue;
    }

    public int getPayType() {
        return payType;
    }

    public void setPayType(int payType) {
        this.payType = payType;
    }
    
    public void setInvoiceValue(double invoiceValue) {
        this.invoiceValue = invoiceValue;
    }

    public Date getPayDate() {
        return payDate;
    }

    public void setPayDate(Date payDate) {
        this.payDate = payDate;
    }

    public String getPayHelp() {
        return payHelp;
    }

    public void setPayHelp(String payHelp) {
        this.payHelp = payHelp;
    }

    public Integer getPayId() {
        return payId;
    }

    public void setPayId(Integer payId) {
        this.payId = payId;
    }

    public String getPayRemarks() {
        return payRemarks;
    }

    public void setPayRemarks(String payRemarks) {
        this.payRemarks = payRemarks;
    }

    public int getPayPro() {
        return payPro;
    }

    public void setPayPro(int payPro) {
        this.payPro = payPro;
    }

    public String getSerialNo() {
        return serialNo;
    }

    public void setSerialNo(String serialNo) {
        this.serialNo = serialNo;
    }

    public FgysEnterprise getEnterpriseInfo() {
        return enterpriseInfo;
    }

    public void setEnterpriseInfo(FgysEnterprise enterpriseInfo) {
        this.enterpriseInfo = enterpriseInfo;
    }

    public List<GczxPayDetail> getPayDetails() {
        return payDetails;
    }

    public void setPayDetails(List<GczxPayDetail> payDetails) {
        this.payDetails = payDetails;
    }

    public int getInvestInterface() {
        return investInterface;
    }

    public void setInvestInterface(int investInterface) {
        this.investInterface = investInterface;
    }

    public boolean isPayed() {
        return payed;
    }

    public void setPayed(boolean payed) {
        this.payed = payed;
    }

    public String getDisplayPayPro() {
        switch (this.payPro) {
            case 1:
                return FacesUtil.getString("list_item_jz");
            case 2:
                return FacesUtil.getString("list_item_cs");
            case 3:
                return FacesUtil.getString("list_item_fgys");
            case 4:
                return FacesUtil.getString("list_item_qyw");
            default:
                return FacesUtil.getString("list_item_default");
        }
    }

     public String getDisplayPayType() {
        switch (this.payType) {
            case 1:
                return FacesUtil.getString("list_item_pay_gcsgf");
            case 2:
                return FacesUtil.getString("list_item_pay_dlgcf");
            case 3:
                return FacesUtil.getString("list_item_pay_zdf");
            case 4:
                return FacesUtil.getString("list_item_pay_qjjsf");
            case 5:
                return FacesUtil.getString("list_item_pay_gzf");
            case 6:
                return FacesUtil.getString("list_item_pay_ttf");
            case 7:
                return FacesUtil.getString("list_item_pay_jlf");
            case 8:
                return FacesUtil.getString("list_item_pay_sjf");
            case 9:
                return FacesUtil.getString("list_item_pay_kcf");
            case 10:
                return FacesUtil.getString("list_item_pay_df");
            case 11:
                return FacesUtil.getString("list_item_pay_zlf");
            default:
                return FacesUtil.getString("list_item_default");
        }
    }

    public String getDisplayInvestInt() {
        switch (this.investInterface) {
            case 1:
                return FacesUtil.getString("list_item_tz_sh_gc");
            case 2:
                return FacesUtil.getString("list_item_tz_sh_fy");
            case 3:
                return FacesUtil.getString("list_item_tz_jt");
            case 4:
                return FacesUtil.getString("list_item_tz_tt");
            default:
                return FacesUtil.getString("list_item_default");
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final GczxPaymentInfo other = (GczxPaymentInfo) obj;
        if (this.payId != other.payId && (this.payId == null || !this.payId.equals(other.payId))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 29 * hash + (this.payId != null ? this.payId.hashCode() : 0);
        return hash;
    }
}